<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>

<body>
    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>

    <div id="app">
        <router-link to="/user/8293?name=孙小双&age=33">用户</router-link>
        <router-link :to="{ path: '/user/123/sunxiaoshuang/22' }">用户2</router-link>
        <router-view />
    </div>

    <script>
        var User = {
            template: `
                <div>
                    <h1>我是用户</h1>
                </div>
            `,
            created() {
              console.log(this)
            },
            watch: {
                $route() {
                    console.log(this);
                }
            },
            data() {
              return {
                code: "sunxiaoshuang"
              }
            },
            props: [ 'id', 'name', 'age' ]
        }

        var routes = [
            { path: "/user/:id", component: User, props: true },
            { path: "/user/:id/:name/:age", component: User, props: true },
        ]
        var router = new VueRouter({
            routes,
        })
        new Vue({
            router
        }).$mount("#app")
    </script>
</body>

</html>